﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="MxWeiXinPF.Web.weixin.toupiao2.index" %>


<% 
    if (!ckHdBegin)
        Response.Redirect("err.aspx");
    else
    { 
%>
<!DOCTYPE html>

<html lang="en" class=" js no-touch cssanimations csstransitions">
<head id="Head1" runat="server">
     <meta charset="UTF-8">
    <title>投票</title>
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <link type="text/css" rel="stylesheet" href="css/style.css">
    <script src="../../scripts/jquery/jquery-2.1.0.min.js"></script>
    <script src="js/layer.m.js"></script>

    <script type="text/javascript">
        $(function () {

            toupiao();
            //搜索
            $("#sou").click(function () {
                var svalue = $("#sea").val();
                //if (svalue != '')
                location.href = "index.aspx?wid=<%=wid%>&aid=<%=aid%>&kw=" + svalue;
            });
            var where = "<%=keywords%>";
            if (where != '')
                $("#sea").val(where);
        });

        //投票
        function toupiao() {
            $(".tou").click(function () {
                //判断活动是否开始

                if ('<%=ckHdBegin%>' == 'True') {


                    var id = $(this).attr("alt");
                    var piaoshuspan = "piao_span_" + id;

                    var req = {
                        openid: "<%=openid%>",
                        wid: "<%=wid%>",
                        actid: "<%=aid%>",
                        memberid: id,
                        radom: Math.random()
                    };

                    $.post("getdata.ashx?mycat=toupiao", req, function (data) {
                        if (data.err == 1) {



                            layer.open({
                                content: data.msg,
                                time: 2,
                                success: function (elem) {
                                    $("#" + piaoshuspan).html(data.newpiao);
                                }

                            });

                        }
                        else {

                            //提示框

                            layer.open({
                                content: data.msg,
                                time: 2,


                            });



                        }
                    }, "json");



                } else {
                    //提示框
                    layer.open({
                        content: '活动未开始或已停止',
                        btn: ['哦，好吧']
                    });
                }
            })
        }
        //获取地址栏指定参数
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }

        window.onscroll = function () {
            //当滚动条到底时，利用ajax加载分页内容
            if (getScrollTop() + getClientHeight() == getScrollHeight()) {
                //读取数据
                var itemSum = $(".zhanshi>.selected").length;

                var req = {
                    itemsum: itemSum,
                    total: '<%=total%>',
                    sort: "<%=sort%>",
                    where: "<%=where%>",
                    wid: "<%=wid%>",
                    actid: "<%=aid%>",
                    pagesize: "<%=pagesize%>",
                    shu: Math.random()
                };

                $.post("getdata.ashx?mycat=scrollItem", req, function (data) {
                    if (data.res == 1) {
                        $(".zhanshi").append(data.content);
                        toupiao();
                    }
                }, "json");
            }
        }

        //获取滚动条当前的位置 
        function getScrollTop() {
            var scrollTop = 0;
            if (document.documentElement && document.documentElement.scrollTop) {
                scrollTop = document.documentElement.scrollTop;
            }
            else if (document.body) {
                scrollTop = document.body.scrollTop;
            }
            return scrollTop;
        }
        //获取当前可视范围的高度 
        function getClientHeight() {
            var clientHeight = 0;
            if (document.body.clientHeight && document.documentElement.clientHeight) {
                clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
            }
            else {
                clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
            }
            return clientHeight;
        }
        //获取文档完整的高度 
        function getScrollHeight() {
            return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
        }
    </script>
</head>
<body> 
     <div class="main">
           
    <div class="banner">
        <div id="wrapper">
            <div id="scroller">
                <ul id="thelist">
                     <%=banner1 %>
                </ul>
            </div>
        </div>
        <div id="nav">
            <div id="prev" onclick="myScroll.scrollToPage('prev', 0,400,<%=bannernum %>);return false">&larr; prev</div>
            <ul id="indicator">
                  <%=banner2 %>
 
            </ul>
            <div id="next" onclick="myScroll.scrollToPage('next', 0,400,<%=bannernum %>);return false">next &rarr;</div>
        </div>
        <div class="clr"></div>
    </div>
     

    <div>
        &nbsp;
    </div>
    
           
           
               
                  <div class="vote-count box">
                        <div class="vote-count-f boxflex"><span>参与人<br>
                            <strong id="join_num">230</strong></span></div>
                        <div class="vote-count-s boxflex"><span>投票数<br>
                            <strong id="vote_num">40225</strong></span></div>
                        <div class="vote-count-t boxflex"><span>浏览量<br>
                            <strong id="pv_num">54004</strong></span></div>
                    </div>

                    <div class="vote-search box">
                        <div class="vote-search-input boxflex">
                            <input id="vote-searchval" type="text" name="" value="">
                        </div>
                        <div class="vote-search-but">
                            <a class="but search" id="vote-search" href="javascript:;">搜索</a>
                        </div>
                    </div>
                    
                      <div id="vote-list" class="vote-list clearfix">
                        <ul class="col">
                            <li class="vote-item" data-id="70655"><a class="goto-detail" data-id="70655" href="javascript:;">
                                <img src="http://3.s.bama555.com/3/201509/01/21bd8606f85f70feb63c41cdd3221aec_640_320.jpg" onload="$.main.home_Scroll.refresh();"></a><p class="name">仁者寿。</p>
                                <p class="code clearfix"><span class="fl">编号:5020</span><span class="fr"><b class="vote-pollsum">84</b>票</span></p>
                                <p><a class="but default vote-totabut" data-id="70655" href="javascript:;">投TA一票</a></p>
                            </li>
                            <li class="vote-item" data-id="72831"><a class="goto-detail" data-id="72831" href="javascript:;">
                                <img src="http://3.s.bama555.com/3/201509/06/dcb4c3f0d15a5a5f7b2d3543e77b4691_640_320.jpg" onload="$.main.home_Scroll.refresh();"></a><p class="name">被认定的专属</p>
                                <p class="code clearfix"><span class="fl">编号:4453</span><span class="fr"><b class="vote-pollsum">774</b>票</span></p>
                                <p><a class="but default vote-totabut" data-id="72831" href="javascript:;">投TA一票</a></p>
                            </li>
                            </ul>
                          </div>

                    
                     
                
    <ul class="cz_san">
        <li class="cyrs">参与人数:<%=member_sum %></li>
        <li class="wycy" onclick="javascript:location.href='canyu.aspx?wid=<%=wid%>&aid=<%=aid %>'">我要参与</li>
        <li class="hdxz" onclick="javascript:location.href='actionBrief.aspx?wid=<%=wid %>&aid=<%=aid %>'">活动须知</li>
    </ul>
    <div class="content">
        <p class="sort">
            <img src="images/sort.jpg" style="width: 28%; margin-top: 10px; margin-left: 8%; float: left;" />
            <img src="images/piaoshu.jpg" style="width: 20%" onclick="javascript:location.href='index.aspx?wid=<%=wid%>&aid=<%=aid %>&sort=piao'" />
            <img src="images/new.jpg" style="width: 20%" onclick="javascript:location.href='index.aspx?wid=<%=wid%>&aid=<%=aid %>&sort=new'" />
        </p>
        <div class="river"></div>
        <p class="search">
            <input type="text" id="sea" placeholder="搜索编号" /><span id="sou">搜索</span>
        </p>

        <%--投票者展示区--%>
        <div class="zhanshi">
            <asp:Repeater ID="rptList" runat="server">
                <ItemTemplate>
                    <div class="selected">
                        <img src="<%#Eval("imgurl")%>" width="100%" onclick="javascript:location.href='memberDetail.aspx?wid=<%=wid%>&&aid=<%=aid %>&mid=<%#Eval("id")%>'" />
                        <span id='piao_span_<%#Eval("id")%>'><%#Eval("piao")%>票</span>
                        <div class="se_dt">
                            <p style="color: #980043; line-height: 30px;">编号：<%#Eval("bianma")%></p>
                            <p><a class="tou" href="javascript:void(0)" alt="<%#Eval("id")%>">投票</a></p>
                        </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
        <%--end投票者展示区--%>
    </div>
    <img src="images/end.jpg" style="width: 100%" />

           </div>

    <link href="/templatesstore/css/iscroll.css" rel="stylesheet" type="text/css" />
    <script src="/templatesstore/js/iscroll.js" type="text/javascript"></script>
    <script type="text/javascript">
        var myScroll;
        function loaded() {
            myScroll = new iScroll('wrapper', {
                snap: true,
                momentum: false,
                hScrollbar: false,
                onScrollEnd: function () {
                    document.querySelector('#indicator > li.active').className = '';
                    document.querySelector('#indicator > li:nth-child(' + (this.currPageX + 1) + ')').className = 'active';
                }
            });
        }

        document.addEventListener('DOMContentLoaded', loaded, false);
    </script>
    <script>
        var count = document.getElementById("thelist").getElementsByTagName("img").length;

        var count2 = document.getElementsByClassName("menuimg").length;
        for (i = 0; i < count; i++) {
            document.getElementById("thelist").getElementsByTagName("img").item(i).style.cssText = " width:" + document.body.clientWidth + "px";

        }
        document.getElementById("scroller").style.cssText = " width:" + document.body.clientWidth * count + "px";

        setInterval(function () {
            myScroll.scrollToPage('next', 0, 400, count);
        }, 3500);
        window.onresize = function () {
            for (i = 0; i < count; i++) {
                document.getElementById("thelist").getElementsByTagName("img").item(i).style.cssText = " width:" + document.body.clientWidth + "px";

            }
            document.getElementById("scroller").style.cssText = " width:" + document.body.clientWidth * count + "px";
        }


    </script>

    <!-- 微信分享 start  -->
    <script type="text/javascript">
        //jssdk
        var dataForWeixin = {
            appId: "<%=fxModel.appid%>",
            MsgImg: "<%=fxModel.fxImg%>",
            TLImg: "<%=fxModel.fxImg%>",
            url: "<%=fxModel.thisUrl%>",
            fxUrl: "<%=fxModel.fxUrl%>",
            title: "<%=fxModel.fxTitle%>",
            desc: "<%=fxModel.fxContent%>",
            timestamp: '<%=fxModel.timestamp%>',
            nonceStr: '<%=fxModel.nonce%>',
            signature: '<%=fxModel.signature%>',
            jsApiList: ["checkJsApi",
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'hideMenuItems',
                    'showMenuItems',
                    'hideAllNonBaseMenuItem',
                    'showAllNonBaseMenuItem',
                    'translateVoice',
                    'startRecord',
                    'stopRecord',
                    'onRecordEnd',
                    'playVoice',
                    'pauseVoice',
                    'stopVoice',
                    'uploadVoice',
                    'downloadVoice',
                    'chooseImage',
                    'previewImage',
                    'uploadImage',
                    'downloadImage',
                    'getNetworkType',
                    'openLocation',
                    'getLocation',
                    'hideOptionMenu',
                    'showOptionMenu',
                    'closeWindow',
                    'scanQRCode',
                    'chooseWXPay',
                    'openProductSpecificView',
                    'addCard',
                    'chooseCard',
                    'openCard'],
            fakeid: "",
            callback: function () { }
        };
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: dataForWeixin.appId, // 必填，公众号的唯一标识
            timestamp: dataForWeixin.timestamp, // 必填，生成签名的时间戳
            nonceStr: dataForWeixin.nonceStr, // 必填，生成签名的随机串
            signature: dataForWeixin.signature,// 必填，签名，见附录1
            jsApiList: dataForWeixin.jsApiList  // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        wx.ready(function () {
            //在此输入各种API
            wx.showOptionMenu();

            //分享到朋友圈 onMenuShareTimeline
            wx.onMenuShareTimeline({
                title: dataForWeixin.title, // 分享标题
                link: dataForWeixin.fxUrl, // 分享链接
                imgUrl: dataForWeixin.MsgImg, // 分享图标
                success: function () {
                    // 用户确认分享后执行的回调函数
                    //fxJia();//分享+1
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            //分享给朋友onMenuShareAppMessage
            wx.onMenuShareAppMessage({
                title: dataForWeixin.title, // 分享标题
                desc: dataForWeixin.desc, // 分享描述
                link: dataForWeixin.fxUrl, // 分享链接
                imgUrl: dataForWeixin.TLImg, // 分享图标
                type: '', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () {
                    // 用户确认分享后执行的回调函数
                    //fxJia();//分享+1
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            //QQ
            wx.onMenuShareQQ({
                title: dataForWeixin.title, // 分享标题
                desc: dataForWeixin.desc, // 分享描述
                link: dataForWeixin.fxUrl, // 分享链接
                imgUrl: dataForWeixin.MsgImg,// 分享图标
                success: function () {
                    // 用户确认分享后执行的回调函数
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            //QQ微博
            wx.onMenuShareWeibo({
                title: dataForWeixin.title, // 分享标题
                desc: dataForWeixin.desc, // 分享描述
                link: dataForWeixin.fxUrl, // 分享链接
                imgUrl: dataForWeixin.TLImg, // 分享图标
                success: function () {
                    // 用户确认分享后执行的回调函数
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
            // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，
            //所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
        });
        wx.error(function (res) {
            console.log(res);
            //  alert('验证失败');
            //alert(res);
            // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
        });



    </script>
    <!-- 微信分享 end  -->
</body>
</html>
<% }%>